#include "countrycombobox.h"

namespace Jcr
{

CountryComboBox::CountryComboBox(QWidget* parent) : QComboBox(parent)
{
    populateList();
}

void CountryComboBox::setCountry(const QString& country)
{
    if (m_countryList.contains(country)) {
        this->setCurrentText(country);
    } else {
        m_countryList.append(country);
        addItem(country);
        setCurrentText(country);
    }
}

QString CountryComboBox::country() const
{
    return currentText();
}

void CountryComboBox::populateList()
{
    m_countryList = QStringList() << "中国" << "美国" << "日本" << "意大利 "
                                  << "奥地利 "<< "德国" << "韩国";
    addItems(m_countryList);
}

} // namespace jcr
